<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<style type="text/css">
	@keyframes rotate{
		0%{
			transform:rotateX(0deg) rotateY(0deg);
		}
		100%{
			transform:rotateX(360deg) rotateY(360deg);
		}
	}
	html{
		background: linear-gradient(#ff0 0%, #000 80%);
		height: 100%;
	}
	.wrap{
		margin-top: 150px;
		perspective:1000px;
	}
	.cube{
		margin:auto;
		width: 200px;
		height: 200px;
		position: relative;
		transform-style: preserve-3d; /* flat */
		/* transform:rotateX(-30deg) rotateY(-70deg); */
		animation:rotate 20s infinite linear;
	}
	.cube > div{
		width: 100%;
		height: 100%;
		position: absolute;
		background-color: #333;
		opacity: .9;
		border:1px #fff solid;
		color: #fff;
		font-size: 36px;
		font-family: "Microsoft Yahei";
		font-weight: bold;
		text-align: center;
		line-height: 200px;
		transition: transform .2s ease-in;
	}
	.cube .out-front{
		transform: translateZ(100px);
	}
	.cube .out-back{
		transform: translateZ(-100px) rotateY(180deg);
	}
	.cube .out-left{
		transform:rotateY(90deg) translateZ(100px);
	}
	.cube .out-right{
		transform:rotateY(-90deg) translateZ(100px);
	}
	.cube .out-top{
		transform:rotateX(90deg) translateZ(100px);
	}
	.cube .out-bottom{
		transform:rotateX(-90deg) translateZ(100px);
	}

	.cube > span{
		display: block;
		width: 100px;
		height: 100px;
		border:1px #000 solid;
		background-color: #999;
		position: absolute;
		top: 50px;
		left: 50px;
	}
	.cube .in-front{
		transform: translateZ(50px);
	}
	.cube .in-back{
		transform: translateZ(-50px) rotateY(180deg);
	}
	.cube .in-left{
		transform:rotateY(90deg) translateZ(50px);
	}
	.cube .in-right{
		transform:rotateY(-90deg) translateZ(50px);
	}
	.cube .in-top{
		transform:rotateX(90deg) translateZ(50px);
	}
	.cube .in-bottom{
		transform:rotateX(-90deg) translateZ(50px);
	}

	.wrap:hover .out-front{
		transform: translateZ(200px);
	}
	.wrap:hover .out-back{
		transform: translateZ(-200px) rotateY(180deg);
	}
	.wrap:hover .out-left{
		transform:rotateY(90deg) translateZ(200px);
	}
	.wrap:hover .out-right{
		transform:rotateY(-90deg) translateZ(200px);
	}
	.wrap:hover .out-top{
		transform:rotateX(90deg) translateZ(200px);
	}
	.wrap:hover .out-bottom{
		transform:rotateX(-90deg) translateZ(200px);
	}
</style>
<body>
	<div class="wrap">
		<div class="cube">
			<div class="out-front">前面</div>
			<div class="out-back">后面</div>
			<div class="out-left">左面</div>
			<div class="out-right">右面</div>
			<div class="out-top">上面</div>
			<div class="out-bottom">下面</div>

			<span class="in-front"></span>
			<span class="in-back"></span>
			<span class="in-left"></span>
			<span class="in-right"></span>
			<span class="in-top"></span>
			<span class="in-bottom"></span>
		</div>
	</div>
</body>
</html>